package com.surveypark.schedule;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.surveypark.service.LogService;
import com.surveypark.util.LogUtil;

public class GenerateLogsTableTask extends QuartzJobBean {

	private LogService logService;
	
	public void setLogService(LogService logService) {
		this.logService = logService;
	}
	
	@Override
	protected void executeInternal(JobExecutionContext arg0)
			throws JobExecutionException {
		
		String tableName =  LogUtil.generateLogTabName(1);
		String sql = "create table if not exists " + tableName + " like logs";
		logService.executeSQL(sql);
		System.out.println(tableName + " 生成了! " );
		
		tableName =  LogUtil.generateLogTabName(2);
		sql = "create table if not exists " + tableName + " like logs";
		logService.executeSQL(sql);
		System.out.println(tableName + " 生成了! " );
	}

}
